#include "gameanimation.h"


GameSeqAnimation::GameSeqAnimation(QObject* parent)
    :QSequentialAnimationGroup(parent)
{
}



void GameSeqAnimation::addMove(QObject* _target, QPointF moveS, QPointF moveE, int duration){
    QPropertyAnimation* moveAnim = new QPropertyAnimation(_target, "pos");
    moveAnim->setDuration(duration);
    moveAnim->setStartValue(moveS);
    moveAnim->setEndValue(moveE);
    this->addAnimation(moveAnim);
}

void GameSeqAnimation::addFade(QObject *_target, qreal fadeS, qreal fadeE, int duration){
    QPropertyAnimation* fadeAnim = new QPropertyAnimation(_target, "opacity");
    fadeAnim->setDuration(duration);
    fadeAnim->setStartValue(fadeS);
    fadeAnim->setEndValue(fadeE);
    this->addAnimation(fadeAnim);
}


GameParAnimation::GameParAnimation(QObject *parent)
    :QParallelAnimationGroup(parent)
{

}

void GameParAnimation::addMove(QObject* _target, QPointF moveS, QPointF moveE, int duration){
    QPropertyAnimation* moveAnim = new QPropertyAnimation(_target, "pos");
    moveAnim->setDuration(duration);
    moveAnim->setStartValue(moveS);
    moveAnim->setEndValue(moveE);
    this->addAnimation(moveAnim);
}

void GameParAnimation::addFade(QObject *_target, qreal fadeS, qreal fadeE, int duration){
    QPropertyAnimation* fadeAnim = new QPropertyAnimation(_target, "opacity");
    fadeAnim->setDuration(duration);
    fadeAnim->setStartValue(fadeS);
    fadeAnim->setEndValue(fadeE);
    this->addAnimation(fadeAnim);
}

void GameParAnimation::addScale(QObject *_target, qreal scaleS, qreal scaleE, int duration){
    QPropertyAnimation* scaleAnim = new QPropertyAnimation(_target, "scale");
    scaleAnim->setDuration(duration);
    scaleAnim->setStartValue(scaleS);
    scaleAnim->setEndValue(scaleE);
    this->addAnimation(scaleAnim);
}
